
<%@ page import="ratemymacclass.Course" %>
<html>
    <head>
         <div class=findUserForm style="float:right">
               <g:formRemote url="[action:'findAClass']" name = "searchWord">
               <g:textField name="searchWord" />
               <g:submitButton name="find A Class" value="Find A Class"/>
               </g:formRemote>
          </div>

        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="layout" content="main" />
        <g:set var="entityName" value="${message(code: 'course.label', default: 'Course')}" />
        <title><g:message code="List of Classes" args="[entityName]" /></title>
    </head>
    <body>
        <div class="nav" style="text-align:center;">
            <span class="menuButton"><a class="home" href="${createLink(uri: '/')}"><g:message code="Home"/></a></span>
            <span class="menuButton"><g:link controller="professor" class="list" action="list">List of Professors</g:link></span>
            <span class="menuButton"><g:link class="create" action="create"><g:message code="Add a new course" args="[entityName]" /></g:link></span>
            <span class="menuButton"><g:link controller="course" class="list" action="showCourseSearch">Find a Professor/Course</g:link></span>

         </div>
  <div id = searchResult>
        </div>
        <div class="body">
            <h1><g:message code="List of Classes" args="[entityName]" /></h1>
            <g:if test="${flash.message}">
            <div class="message">${flash.message}</div>
            </g:if>
            <div class="intro">Tip: Click and sort by department, title or course number</div>
            <div class="list">
                <table>
                    <thead>
                        <tr>
                        
                            <%--g:sortableColumn property="id" title="${message(code: 'course.id.label', default: 'Id')}" /--%>
                        
                            <g:sortableColumn property="title" title="${message(code: 'course.title.label', default: 'Title')}" />
                        
                            <g:sortableColumn property="department" title="${message(code: 'course.department.label', default: 'Department')}" />
                        
                            <g:sortableColumn property="courseNum" title="${message(code: 'course.courseNum.label', default: 'Course Num')}" />
                        
                        </tr>
                    </thead>
                    <tbody>
                    <g:each in="${courseInstanceList}" status="i" var="courseInstance">
                        <tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
                        
                            <%--td><g:link action="show" id="${courseInstance.id}">${fieldValue(bean: courseInstance, field: "id")}</g:link></td--%>
                        
                            <td><g:link action="show" id="${courseInstance.id}">${fieldValue(bean: courseInstance, field: "title")}</g:link></td>
                        
                            <td>${fieldValue(bean: courseInstance, field: "department")}</td>
                        
                            <td>${fieldValue(bean: courseInstance, field: "courseNum")}</td>
                        
                        </tr>
                    </g:each>
                    </tbody>
                </table>
            </div>
            <div class="paginateButtons">
                <g:paginate total="${courseInstanceTotal}" />
            </div>
            <br />
            <div class="suggestion">Can't find the right class you are looking for? Add a new class <g:link class="create" action="create"><g:message code="here" args="[entityName]" /></g:link>.</div>
        </div>
    </body>
</html>
